<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class MassageChangeRecord
 *
 * @property int $id
 * @property int|null $user_id
 * @property int|null $order_id
 * @property string|null $old_img_id_list
 * @property string|null $img_id_list
 * @property string|null $id_type
 * @property string|null $old_id_type
 * @property string|null $old_img_card_id
 * @property string|null $img_card_id
 * @property string|null $old_user_name
 * @property string|null $user_name
 * @property string|null $old_address_code
 * @property string|null $address_code
 * @property string|null $old_count_num
 * @property string|null $count_num
 * @property int|null $old_bank_card_id
 * @property int|null $bank_card_id
 * @property string|null $old_phone_num
 * @property string|null $phone_num
 * @property string|null $old_address
 * @property string|null $new_address
 * @property string|null $old_email
 * @property string|null $new_email
 * @property int|null $record_type
 * @property int|null $is_pass
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 *
 * @property BankCard|null $bank_card
 * @property Order|null $order
 * @property User|null $user
 * @property Collection|OaRecord[] $oa_records
 *
 * @package App\Models
 */
class MassageChangeRecord extends Model
{
	protected $table = 'massage_change_record';

	protected $casts = [
		'user_id' => 'int',
		'order_id' => 'int',
		'old_bank_card_id' => 'int',
		'bank_card_id' => 'int',
		'record_type' => 'int',
		'is_pass' => 'int'
	];

	protected $fillable = [
		'user_id',
		'order_id',
		'old_img_id_list',
		'img_id_list',
		'id_type',
		'old_id_type',
		'old_img_card_id',
		'img_card_id',
		'old_user_name',
		'user_name',
		'old_address_code',
		'address_code',
		'old_count_num',
		'count_num',
		'old_bank_card_id',
		'bank_card_id',
		'old_phone_num',
		'phone_num',
		'old_address',
		'new_address',
		'old_email',
		'new_email',
		'record_type',
		'is_pass'
	];

    public function bank_card()
    {
        return $this->belongsTo(BankCard::class, 'bank_card_id');
    }

    public function old_bank_card()
    {
        return $this->belongsTo(BankCard::class, 'old_bank_card_id');
    }

    public function order()
    {
        return $this->belongsTo(Order::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function oa_records()
    {
        return $this->hasMany(OaRecord::class, 'massage_change_id');
    }
}
